package com.example.shiro.model.sys.mapper;

import com.example.shiro.model.sys.entity.RoleAuthEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 角色权限连接表 Mapper 接口
 * </p>
 *
 * @author jatej
 * @since 2020-04-16
 */
public interface RoleAuthMapper extends BaseMapper<RoleAuthEntity> {

    /**
     * 通过用户ID查询权限标识集合
     * @param userId
     * @return
     */
    @Select("SELECT auth_remark FROM sys_auth AS sa JOIN sys_role_auth AS sru ON  sa.auth_id = sru.auth_id" +
            "  JOIN sys_role AS sr ON sr.role_id = sru.role_id " +
            "  JOIN sys_user_role AS sur ON sur.role_id = sr.role_id" +
            "  WHERE sur.user_id = #{userId}")
    Set<String> getAuthNameByUserId(Integer  userId );
}
